﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Entities;
using BusinessLogic;
namespace GUI
{
    public partial class PRDT001 : UserControl
    {
        public PRDT001()
        {
            InitializeComponent();
        }
        private BllProduct _productData;
        
        private void button1_Click(object sender, EventArgs e)
        {
            UpdateProduct();
        }
        private void LoadData()
        {
            var listProduct = _productData.GetAll();
            dataGridView1.DataSource = listProduct.ToList();
        }
        private void UpdateProduct()
        {
            var product = _productData.GetAll().Where(r => r.ID == 1).FirstOrDefault();
            product.Name = "888888";
            _productData.UpdateObject(product);
            LoadData();
        }
        private void CreateProduct()
        {
            Product product = new Product();
            product.Name = "name1";
            product.ImageURL = "URL1";
            _productData.AddObject(product);
            LoadData();

        }

        private void UserControl1_Load(object sender, EventArgs e)
        {
            _productData = new BllProduct();
            LoadData();
        }
    }
}
